// ***************************************************************************
// Caution: modifying this file will affect the integrity of the application.
// ***************************************************************************
// Copyright � 1995-2007, Camstar Systems, Inc. All Rights Reserved.
// This file is in use with the single pane section

// Selected Sub Menu Item
var mSelectedSinglePaneItem = null;

// Submenu item has been slected 
function SelectSinglePaneItem(id, pageName, pageTitle, helpPageName) {
  // Get the source element
  var menuItem = GetSourceElement();
  if (menuItem == null) return;

  // Select the item
  SelectItem(id);

  // Create the new section
  CreateSinglePaneSection(pageName, pageTitle, helpPageName);
} // SelectSinglePaneItem

// Submenu item has been slected 
function SelectShopFloorItem(id, pageName, pageTitle, serviceType, helpPageName) {
  if (pageName.indexOf("ProductWorkflowDataViewVue3Page") !== -1 && navigator.userAgent.indexOf('Trident') != -1) { openVueByChrome(pageName) } else {
    // Select the item
    SelectItem(id);

    // Set the service name and unique id before passing the page
    pageName = pageName + '?' + top.QueryStringServiceType + '=' + serviceType;

    // Create the new section
    CreateSinglePaneSection(pageName, pageTitle, helpPageName);
  }
} // SelectShopFloorItem

// Set the pieces of the single pane working section 
function CreateSinglePaneSection(pageName, pageTitle, helpPageName) {
  // Get a unique instance id for the page and buttons iframes to use
  var pageInstanceId = ReturnPageInstanceId();

  // Set the title
  SetSinglePaneTitle(pageTitle);

  // Set the page src
  SetSinglePanePage(pageName, pageInstanceId, helpPageName);

  // Clear the message
  WriteMessage('', true);

  // Set the help page name
  SetHelpPageName(helpPageName);
} // CreateSinglePaneSection

// Set the Title
function SetSinglePaneTitle(pageTitle) {
  if (gDoc[top.CtrlTitleCell] != null) {
    gDoc[top.CtrlTitleCell].innerText = pageTitle;
  } // if
} // SetSinglePaneTitle

// Set the Page
function SetSinglePanePage(pageName, pageInstanceId, helpPageName) {
  if (document.frames.pageIframe != null) {
    pageInstanceId = top.QueryStringPageInstanceId + '=' + pageInstanceId;
    helpPageName = top.QueryStringHelpPageName + '=' + helpPageName;
    // Add the page instance id and help page
    if (HasQueryString(pageName)) {
      pageName = pageName + '&' + pageInstanceId + '&' + helpPageName;
    }
    else {
      pageName = pageName + '?' + pageInstanceId + '&' + helpPageName;
    } // if else
    document.frames.pageIframe.location = pageName;
  } // if    
} // SetSinglePanePage

function openVueByChrome(url) {
  var currentUserInfo = window.parent.document.getElementById('currentUserInfo').innerText;
  url = 'http://' + window.location.hostname + url;
  var data = {};
  var objShell = new ActiveXObject("WScript.Shell");
  var cmd = 'cmd.exe /c start chrome " ' + url + '?uid=' + currentUserInfo;
  objShell.Run(cmd, 0, true);
}